#include "stdio.h"
#include "stdlib.h"
#include "cwit_list.h"
#include "cwit_string.h"
#include "cwit_map.h"
typedef struct __TestData{
    int index;
    char dat[32];
}TestDat;

TestDat * mallocTest(int index,char *aaa)
{
    TestDat *dat = malloc(sizeof(TestDat));
    memset(dat,0,sizeof(TestDat));
    dat->index = index;
    memcpy(dat->dat,aaa,strlen(aaa));
    return dat;
}
int con(void*f,void *da,void *ne)
{
    TestDat *fd =(TestDat *)f;
    TestDat *dat = (TestDat *)da;
    TestDat *nes = (TestDat*)ne;
    int d1 = fd == NULL?0:fd->index;
    int d2 = dat == NULL?0:dat->index;
    int d3 = nes == NULL?0:nes->index;
    printf("%d %d %d\r\n",d1,d2,d3);
    if(d2 %6 == 0)
    {
        free(da);
        return 1;
    }
    return 0;
}
int ppp(void*f,void *da,void *ne)
{
    printf("%s \r\n",(char *)da);
}

void tes(cwit_list *list,void *d)
{
    printf("%d\r\n",(int *)d);
    cwit_list_push_tail(list,d);
}
void maprin(void *index,void *dat)
{
    TestDat *fd =(TestDat *)dat;
printf("%s %d %s\r\n",(char *)index,fd->index,fd->dat);
}
int main()
{
    // cwit_list list;
    // memset(&list,0,sizeof(cwit_list));
    // tes(&list,1);
    // // cwit_list_push_tail(&list,mallocTest(1,"111"));
    // // cwit_list_push_tail(&list,mallocTest(2,"222"));
    // // cwit_list_push_tail(&list,mallocTest(3,"333"));
    // // cwit_list_push_tail(&list,mallocTest(4,"444"));
    // // cwit_list_push_tail(&list,mallocTest(5,"555"));
    // // cwit_list_push_tail(&list,mallocTest(6,"666"));
    // // cwit_list_remove_condition(&list,con);
    // // cwit_list_remove_value(&list,mallocTest(3,"333"),sizeof(TestDat),0);
    // // printf("\r\nstart test:%d \r\n",cwit_list_size(&list));
    // // cwit_list_traversal(&list,ppp);
    char data[32];
    memset(data,0,32);
    memcpy(data,"111,22,333,44,523,46,sss",32);
    cwit_list*list = cwit_string_split_to_list(data,"511");
    cwit_list_traversal(list,ppp,NULL);

    // cwit_map map;
    // memset(&map,0,sizeof(cwit_map));
    // map.capacity = 7;
    // cwit_map_insert(&map,"1112",strlen("1112"),mallocTest(1,"111"));
    // cwit_map_insert(&map,"1112",strlen("1112"),mallocTest(1,"111"));
    
    // cwit_map_insert(&map,"1112",strlen("1112"),mallocTest(1,"111"));
    // cwit_map_remove_key(&map,"1112",strlen("1112"));
    // // cwit_map_insert(&map,"1113",strlen("1112"),mallocTest(1,"111"));
    // int  a= 49;
    // cwit_map_insert(&map,&a,sizeof(a),mallocTest(2,"131"));
    // cwit_map_get_value(&map,&a,sizeof(int));
    // cwit_map_traversal(&map,maprin);
    return ;
}